package chapter8;

import java.util.Scanner;

public class CalculateTest {

    public static void main(String[] args) {
        Calculate ca=new Calculate();
        Scanner input=new Scanner(System.in);
        System.out.println("请输入操作的第一个数");
        int num1=input.nextInt();
        System.out.println("请输入操作的第二个数");
        int num2=input.nextInt();
        System.out.println("请输入运算符【+ - * /】");
        String op=input.next();
        int result=0;

        switch (op){
            case "+":
                result=ca.add(num1,num2);
                break;
            case "-":
                result=ca.sub(num1,num2);
                break;
            case "*":
                result=ca.mul(num1,num2);
                break;
            case "/":
                if(num2==0){
                    System.out.println("除数不能为0");
                    break;
                }
                result=ca.mod(num1,num2);
                break;
            default:
                System.out.println("你选择的操作符不正确");

        }
        System.out.println("运算的结果为"+result);



    }

}
